/*
 * Copyright 2012 Faculty of Informatics - Masaryk University.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package cz.muni.fi.pa165.creatures.services;

import cz.muni.fi.pa165.creatures.dao.exceptions.WeaponEffectivityException;
import cz.muni.fi.pa165.creatures.dto.CreatureTypeDTO;
import cz.muni.fi.pa165.creatures.dto.CreatureTypeWeaponDTO;
import cz.muni.fi.pa165.creatures.dto.WeaponDTO;
import java.util.List;

/**
 * This interface offers API for the implementation in order to be able execute
 * very basic crud-like operations upon effectivity-creature type - weapon
 * relationship.
 *
 * @author xmiklos1
 */
public interface EffectivityService {

    static final int MAX_WEAPONS_OF_CREATURE_TYPE = 3;

    /**
     * This method adds effectivity of a weapon to a creature type.
     *
     * @param creatureType creature type we want to associate weapon effectivity
     * to
     * @param weaponDTO weapon we want to set an effectivity against some
     * creature type of
     * @param effectivity effectivity of a weapon against particular creature
     * type
     * @throws WeaponEffectivityException if we try to insert more than
     * {@link EffectivityService#MAX_WEAPONS_OF_CREATURE_TYPE} associations
     */
    void addEffectivity(CreatureTypeDTO creatureType, WeaponDTO weaponDTO,
            Float effectivity) throws WeaponEffectivityException;

    /**
     * This method removes effectivity relationship between creature type and
     * some weapon.
     *
     * @param creatureType the type of creature
     * @param weaponDTO the weapon
     */
    void removeEffectivity(CreatureTypeDTO creatureType, WeaponDTO weaponDTO);

    /**
     * This method removes all effectivity relationships of some weapon.
     * 
     * @param weaponDTO weapon to delete all effectivities of 
     */
    void removeAllEffectivities(WeaponDTO weaponDTO);
    
    /**
     * This method updates an effectivity association.
     *
     * @param creatureType creature type to set in this relationship
     * @param weaponDTO weapon to set in this relationship
     * @param effectivity effectivity to set to this relationship
     */
    void updateEffectivity(CreatureTypeDTO creatureType, WeaponDTO weaponDTO,
            Float effectivity);

    /**
     * Gets all creature type - weapon association of some creature type.
     *
     * @param id id of a type of creature
     * @return list of all creature type - weapon associations
     */
    List<CreatureTypeWeaponDTO> getAllByCreatureType(Long id);

    /**
     * Removes relation between creatureType and weapon.
     *
     * @param creatureTypeId - id of creature type
     * @param weaponId - id of weapon
     */
     void removeEffectivity(Long creatureTypeId, Long weaponId);

     /**
      * Returns number of weapon assocition to given creatureType. It finds
      * creatureType in DB (by Id).
      *
      * @param creatureTypeId id of type of creature
      * @return number of associated weapons to given creatureType
      */
     Integer getCountOfEffectivitiesByCreatureType(Long creatureTypeId);
}
